/*
 *时间块文件
 */
'use strict';
import React, { Component } from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import { formatTime } from '@app/constants/CommonFn.jsx';

const dayArr = ['日','一','二','三','四','五','六'];

export default class TimeDom extends Component {
	constructor(props) {
  	super(props);
  	// props.GetWeather();
		this.state = {
			time:new Date(),
		};
		this.clockTime();
  }

	componentWillUnmount(){
		clearInterval(this.timer);
	}
	
	clockTime = () =>{
  	this.timer = setInterval(() => {
  		const time = new Date();
  		this.setState({time});
  	},1000);
  }

  render() {
  	return (
			<div>
				<p>{formatTime(this.state.time,'yyyy年mm月dd')}日</p>
				<p>星期{dayArr[this.state.time.getDay()]}</p>
				<p style = {{color:'#008CFF'}}>{formatTime(this.state.time,'hh:ff:ss')}</p>
			</div>
  	)
  }

}